package com.bemyapp;

import com.bemyapp.mp.MP;
import com.bemyapp.tts.ParrotTTSObserver;
import com.bemyapp.tts.ParrotTTSPlayer;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.PowerManager;
import android.provider.MediaStore.Audio.Media;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;

public class WhereisbryanActivity extends Activity implements ParrotTTSObserver {
	
	PowerManager.WakeLock wl;
	ImageButton bRepeat, bTranslation;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        setVolumeControlStream(AudioManager.STREAM_MUSIC);

		bRepeat = (ImageButton) findViewById(R.id.buttonRepeat);
		bRepeat.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivity(new Intent(WhereisbryanActivity.this, RepeatActivity.class));
			}
		});
		bTranslation= (ImageButton) findViewById(R.id.buttonTranslation);
		bTranslation.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				startActivity(new Intent(WhereisbryanActivity.this, TranslationActivity.class));	
			}
		});
		
		
		
    }
    
    public void onResume(){
    	super.onResume();
       /* PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
        wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "whereisbryan");
        wl.acquire();*/
    }
    
    

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		if(keyCode==KeyEvent.KEYCODE_DPAD_DOWN) {
			bTranslation.requestFocus();
		}
		else if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
			bRepeat.requestFocus();
		}
		return super.onKeyDown(keyCode, event);
	}
    
    public void onPause(){
    	super.onPause();
    	//if (wl != null) wl.release();
    }



	@Override
	public void onTTSFinished() {
		// TODO Auto-generated method stub
		
	}



	@Override
	public void onTTSAborted() {
		// TODO Auto-generated method stub
		
	}
}